// @ts-nocheck
import {useEffect, useState} from 'react'
import {queryDistrict} from '@/services/district'
import {Select} from 'antd'

const DistrictSelect = (props) => {
  const {defaultValue, onChange} = props
  const [data, setData] = useState([])
  const [value, setValue] = useState(null)
  useEffect(() => {
    queryDistrict({}).then(res => {
      setData(res.data)
    })
  }, [])
  useEffect(() => {
    setValue(defaultValue)
  }, [defaultValue])
  return (
    <Select
      value={value}
      allowClear
      showSearch
      onChange={onChange}
      placeholder={'请选择所属区域'}
    >
      {data.map(v => <Select.Option key={v.district_id} value={v.district_id}>{v.name}</Select.Option>)}
    </Select>
  );
};

export default DistrictSelect;
